/*
 * Copyright (C) 2012 Jesse Webb (gweebz@gmail.com)
 *
 * This file is part of Gwahtzee.
 *
 * Gwahtzee is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Gwahtzee is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Gwahtzee.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.googlecode.gwahtzee.gui.mainmenu;

import org.newdawn.slick.Input;

import java.util.ArrayList;
import java.util.List;

public class Menu {
    private List<Button> buttons;

    public Menu() {
        this.buttons = new ArrayList<Button>();
    }

    public void update(Input input, int mouseX, int mouseY, int delta) {
        for (Button button : buttons) {
            button.update(mouseX, mouseY, delta);
        }

        for (Button button : buttons) {
            if (button.isMouseOver()) {
                if (input.isMousePressed(Input.MOUSE_LEFT_BUTTON)) {
                    button.click();
                }
            }
        }
    }

    public void render() {
        for (Button button : buttons) {
            button.render();
        }
    }

    public void addButton(Button button) {
        buttons.add(button);
    }
}
